package com.example.android.ui.widget

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.constraintlayout.widget.ConstraintLayout

/**
 * @author zjc
 * @date 2022/11/23
 */
class TouchView : ConstraintLayout {

    constructor(context: Context) : this(context, null)

    constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)

    constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : super(context, attrs, defStyleAttr)

    override fun onTouchEvent(event: MotionEvent?): Boolean {
        when (event?.action) {
            MotionEvent.ACTION_MOVE ->
            parent.requestDisallowInterceptTouchEvent(true);
            MotionEvent.ACTION_UP,
            MotionEvent.ACTION_CANCEL ->
            parent.requestDisallowInterceptTouchEvent(false);
        }
        return super.onTouchEvent(event)
    }
}